<template>
	<view>
		<u-navbar title="卡添加" />
		<formz ref="formz" :inputs="inputs" :data="data">
		</formz>
		<fixedbtn>
			<view class="fixedbtnbox">
				<u-button :loading="loading" type="primary" @click="confirmfn">{{$z.$t("添加")}}</u-button>
			</view>
		</fixedbtn>
		<zmodal ref="zmodal"></zmodal>
	</view>
</template>

<script>
	import json from "./cardjson.js"
	import settingvue from "@/mixins/setting.vue"
	export default {
		mixins: [settingvue],
		data() {
			return {
				inputs: json.addjson,
				data: {},
				loading: false
			}
		},
		mounted() {
			this.init()
		},
		methods: {
			async init() {
				await this.$store.dispatch("user/getUSearch")
				await this.$store.dispatch("upw/getUpw")
				let user = this.$store.state.user.USearch
				let pcs = await this.$store.dispatch('station/getstationfn', user.pcs)
				this.$refs.formz.init()
			},
			async confirmfn() {
				let data = await this.$refs.formz.validate();
				if (data.yxq == '') {
					delete data.yxq
				}
				this.loading = true
				let par = await this.$z.request("/Cardsedt", data)
				if (par[0].par == "succeed") {
					this.$refs.zmodal.init({
						content: this.$z.$t("操作成功"),
						confirm: () => {
							this.$z.back()
						}
					})

				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	.fixedbtnbox {
		width: 100%;
		padding: 0 30rpx;
	}
</style>